import {
  Controller,
  Get,
  SetMetadata,
  UseGuards,
  Headers,
  Query,
  ParseIntPipe,
} from '@nestjs/common';
import { AppService } from './app.service';
import { AaaGuard } from './aaa.guard';
import { Aaa } from './aaa.decorator';
import { Bbb } from './bbb.decorator';
import { Ccc } from './ccc.decorator';
import { MyHeader } from './my-header.decorator';
import { log } from 'console';
import { MyQuery } from './my-query.decorator';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @Aaa('admin')
  @UseGuards(AaaGuard)
  getHello(): string {
    return this.appService.getHello();
  }

  @Get('/hello2')
  @Aaa('admin')
  @UseGuards(AaaGuard)
  getHello2(): string {
    return this.appService.getHello();
  }

  @Bbb('/hello3', 'admin')
  getHello3(): string {
    return this.appService.getHello();
  }

  @Get('/hello4')
  getHello4(@Ccc() c): string {
    return c;
  }

  @Get('/hello5')
  getHello5(@Headers('accept') Headers1, @MyHeader('accept') Headers2) {
    log(Headers1);
    log(Headers2);
    log(Headers1 === Headers2);
    return Headers1;
  }

  @Get('/hello6')
  getHello6(
    @Query('aaa', new ParseIntPipe()) aaa,
    @MyQuery('bbb', new ParseIntPipe()) bbb,
  ) {
    log(aaa);
    log(bbb);
    return aaa + bbb;
  }
}
